<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.*, loginbean.*" %>
<%ObjectMap objectList = new ObjectMap(new Integer(session.getAttribute("tenantid").toString()).intValue()); %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Display Objects</title>
<SCRIPT language="JavaScript">

function editObject( objId )
{
	document.displayForm.selectedObject.value=objId;
	document.displayForm.action="edit.jsp";
}
function deleteObject( objId )
{
	document.displayForm.selectedObject.value=objId;
	document.displayForm.action="delete.jsp";
}

</SCRIPT>
</head>
<body>

<form method="POST" name="displayForm" action="">
<input type="hidden" name="selectedObject" value="">
<table border="1">
<tr>
	<th>Object Name</th><th>Edit Object</th><th>Delete Object</th>
</tr>

<%
	Iterator objectNames = objectList.keySet().iterator();
	while( objectNames.hasNext() )
	{
		String objectId = (String)objectNames.next();
		ObjectBean obj = (ObjectBean)objectList.get(objectId);
		String objectName = obj.getName();
		out.println("<tr><td>");
		out.println(objectName + "</td><td>");
		out.print( "<input type=\"submit\" name=\"Submit\" value=\"Edit Object\" onClick=\"editObject('"+ objectId +"')\">" );
		out.println("</td><td>");
		out.print( "<input type=\"submit\" name=\"Submit\" value=\"Delete Object\" onClick=\"deleteObject('"+ objectId +"')\">");
		out.println("</td></tr>");
	}
%>

</table>
</form> 
<br><a href="welcome.jsp">Main Menu</a>
</body>
</html>